package utils

import (
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
)

func PostStockByCode(code string) error {
	fmt.Printf("Post Create stock: %s\n", code)
	resp, err := http.Post(STOCK_HOST+"/stock/"+code, "application/json", nil)
	if err != nil {
		return err
	}

	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Printf("responseBody: %s\n", string(body))
	if resp.StatusCode != 200 {
		return errors.New("Failed")
	}
	return err
}
